﻿@{
    ViewBag.LeftTitle = "供应商";
    ViewBag.RightTitle = "采购明细";
    Layout = "~/Views/Shared/_LayoutTree.cshtml";
}
@section Left{
    @(Html.nbTree(s =>
    {
        s.Action("PlanTree");
        s.layoutH(30);
        s.Width(200);
        s.Sync(false);
        s.Grid("SupplierId", gridActionUrl: "PlanList");
    }))
}
@section Right{
    @(Html.nbGridFor<MaterialPurchasePlanView>(s =>
    {
        s.layoutW(208);
        s.layoutH(146);
        s.ShowCheckBox(false);
        s.ExtParam(new { date = @DateTime.Today.AddDays(1).ToString("yyyy-MM-dd") });
        s.SummaryTemplate("采购量：<b>${PurchaseWeight}</b> 斤，总金额：<b>${PurchasePrice}</b> 元");
        s.Columns(c =>
        {
            c.Bind(m => m.Id).IsKey();
            c.BindDateTime(m => m.Date).Width(70).AsSearch().Title("订单日期");
            //c.Bind(m => m.SupplierName).Width(100).Align(GridAlign.Left).AsSearch().Title("供应商名称");
            c.BindEnum(m => m.Category, "MaterialCategory").Width(60).AsSearch().Title("品名分类");
            c.Bind(m => m.Code).Width(60).AsQuery().AsSearch().Title("编号");
            c.Bind(m => m.Name).Width(100).Align(GridAlign.Left).AsQuery().AsSearch().Title("名称");
            c.Bind(m => m.Price).Width(30).Align(GridAlign.Right).Title("单价");
            c.Bind(m => m.PurchaseWeight).Width(70).Align(GridAlign.Right).Title("需采购量(斤)").Summary(SummaryType.Sum);
            c.Bind(m => m.PurchasePrice).Width(50).Align(GridAlign.Right).Title("采购金额").Summary(SummaryType.Sum);
            c.Bind(m => m.TotalWeight).Width(70).Align(GridAlign.Right).Title("订单量(斤)");
            c.Bind(m => m.ActualStorage).Width(70).Align(GridAlign.Right).Title("实际库存(斤)");
            c.Bind(m => m.SafeStorage).Width(70).Align(GridAlign.Right).Title("安全库存(斤)");
        });
        s.Buttons(b =>
        {
            b.BindAddButton("生成明天采购单").Action(Url.Action("Edit", "MaterialPurchase", new { SupplierId = "{TreeId}", Date = @DateTime.Today.AddDays(1).ToString("yyyy-MM-dd") }));
        });
    }))
}
